import axios from "axios";
import { defineStore } from "pinia";
import { nanoid } from "nanoid";
import { reactive } from "vue";
// export const useTalkStore=defineStore("talk",{
//     actions: {
//         async Get() {
//             let result=await axios.get('http://api.uomg.com/api/rand.qinghua?format=json');
//             let obj={id: nanoid(),title: result.data.content};
//             this.talkList.unshift(obj);
//         }
//     },
//     state(){
//         return {
//             talkList: JSON.parse(localStorage.getItem('talkList') as string) || [],
//         }
//     }
// })
const useTalkStore=defineStore("talk",()=>{
    const talkList=reactive([
        {
            id: "01",
            title: "起始标志"
        },
    ]);
    async function  Get() {
        let result=await axios.get('http://api.uomg.com/api/rand.qinghua?format=json');
        let obj={id: nanoid(),title: result.data.content};
        talkList.unshift(obj);
    }
    return {talkList,Get};
})
export default useTalkStore